home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 38
/
Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso
/
-seriously_amiga-
/
archivers
/
lzhutils_src
/
xsplit.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-25
|
2KB
|
76 lines
/*
* XSplit - Split a file into more <smaller> files.
*
*
* Copyright © 1995 The Xperts Group Inc. All Rights Reserved.
* Author: Manolis S Pappas.
* Version: 1.1a
*
*
*/
#include <stdio.h>
#include <string.h>
#define VERSION "1.1a"
#define EXIT_FAILURE 1
static const char versid[]="$VER: XSplit v1.1a (7.1.96)";
FILE *open_vol(name, no)
char *name;
long no;
{
char work[1024];
if (no)
sprintf(work, "%s.%02d", name, no);
else
sprintf(work, "%s.000", name);
return fopen(work, "wb");
}
int main(argc, argv)
int argc;
char **argv;
{
char buffer[1024]; /* Small I/O buffer */
FILE *in, *out;
long size, i, j = 1024, vol_no = 0;
if (argc != 4) {
printf("XSplit v%s\n",VERSION);
printf("Copyright (©) 1995-96, The Xperts Group Inc.\n");
printf("All Rights Reserved Worldwide.\n");
printf("Author: Manolis S Pappas.\n\n");
printf("Usage: %s <basefilesize in KB> <infile> <outbasename>\n", argv[0]);
exit(EXIT_FAILURE);
}
size = atoi(argv[1]);
if (in = fopen(argv[2], "rb")) {
while (!feof(in)) {
if (out = open_vol(argv[3], vol_no++)) {
i = size;
while((i--) && (j == 1024)) {
j = fread(buffer, 1, 1024, in);
fwrite(buffer, 1, j, out);
}
fclose(out);
} else {
fclose(in);
printf("Error opening volume %d!\n\n", vol_no);
exit(EXIT_FAILURE);
}
}
} else {
printf("Error opening source!!\n\n");
exit(EXIT_FAILURE);
}
return 0;
}